import Router from 'koa-router'
import UserRepository from '../repositories/user'

const repo = new UserRepository()
const userRouter = new Router()

userRouter.get('/', async (ctx, next) => {
  const res = await repo.getList()
  ctx.body = res
})

userRouter.post('/', async (ctx, next) => {
  const newUser = ctx.request.body
  const res = await repo.addOne(newUser)
  ctx.body = res
})

export default userRouter
